from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

# 1.打开浏览器
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path='../01/chromedriver.exe')
# driver = webdriver.Chrome() #创建浏览器对象
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大浏览器页面
driver.maximize_window()
# 输入用户名：admin1
username = driver.find_element_by_css_selector("#userA")
username.send_keys("admin1")
# 暂停2秒
sleep(2)
# 删除1
username.send_keys(Keys.BACK_SPACE)
# 暂停2秒
sleep(2)
# 全选用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL, 'a')
# 暂停2秒
sleep(2)
# 复制用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL, 'c')
# 暂停2秒
sleep(2)
# 粘贴到密码框
# 定位到密码框，执行Ctrl+v
password = driver.find_element_by_css_selector("#passwordA")
password.send_keys(Keys.CONTROL, 'v')
